package com.medicine.sys.controller;

import com.medicine.common.base.ResponseData;
import com.medicine.sys.entity.Merchant;
import com.medicine.sys.entity.Organization;
import com.medicine.sys.param.MerchantParam;
import com.medicine.sys.param.OrganizationParam;
import com.medicine.sys.service.MerchantService;
import com.medicine.sys.service.OrganizationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "组织管理")
@RestController
@RequestMapping("/organization")
public class OrganizationController {

    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value="组织列表查询")
    @GetMapping("/list")
    public ResponseData list(OrganizationParam organizationParam){
        return ResponseData.success("查询成功！",organizationService.selectList(organizationParam));
    }

    @ApiOperation(value="组织新增")
    @PostMapping
    public ResponseData install(Organization organization){
        organizationService.install(organization);
        return ResponseData.success("新增成功！");
    }


    @ApiOperation(value="组织修改")
    @PutMapping
    public ResponseData update(Organization organization){
        organizationService.install(organization);
        return ResponseData.success("修改成功！");
    }

    @ApiOperation(value="组织详情查询")
    @GetMapping("/{id}")
    public ResponseData list(@PathVariable String id){
        return ResponseData.success("查询成功！",organizationService.getId(id));
    }
}
